/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interpreter;

import ast.*;
import java.util.ArrayList;

/**
 *
 * @author Stephen
 */
public class CallFunction {
    
    private AST t;
    
    public CallFunction(AST t, InterpreterVisitor iv) {
        this.t = t;
    }
    
    public Object execute() {
        String funcName = ((IdTree) t.getKid(1)).getSymbol().toString();
        ArrayList args = new ArrayList();
        int i = 2;
        while (t.getKid(i) != null) {
            args.add(t.getKid(i));
            i++;
        }
        return SymbolTable.Scope.getFunction(funcName).execute(args);
    }
}
